import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'headOfficeM',

  state: {},

  effects: {
    //查询存款总行数据
    *queryTableList({ payload, callback }, { call, put }) {
      const response = yield call(api.headOffice.queryHeadOffice, payload);
      if (response && response.code == 0) {
        response.data.columns.forEach((value) => {
          if (value.key == 'vcBankName') {
            value['width'] = 220;
          } else if (value.key == 'enCoreCapitalRatio' || value.key == 'enCapitalRatio') {
            value['type'] = 'rate';
            value['width'] = 150;
          } else if (value.key == 'enLastyearCapital' || value.key == 'enLastyearAsset') {
            value['type'] = 'money';
            value['width'] = 130;
          } else {
            value['width'] = 95;
          }
        });
        callback('success', response.data);
      } else {
        callback('fail');
        message.error(`查询存款总行列表失败，失败原因：${response?.msg}`);
        console.error(`查询存款总行列表失败，失败原因：${response?.msg}`, '接口名称： queryBank 接口：instrument-server/depositBank/queryBank');
      }
    },

    reducers: {
      save(state, { payload }) {
        return {
          ...state,
          ...payload,
        };
      },
    },
  },
};
